home *** CD-ROM | disk | FTP | other *** search
- Here's a little proc I made today in 15 mins.
- It was made because the JD_Lib's input-command crashed my machine
- every time I used it, and I missed the editing facilities (cursor key/del
- support and default string).
-
- Note: You can't give strings with spaces at the end of line...
- like "asdsadsada ", the param$ will contain
- "asdsadsada".
-
- Procedure _INPUT[X,Y,_DEF$,_MAXLEN,_MOUSE]
- 'This proc was made by <veijalai@cc.lut.fi>
- 'X,Y - coordinates
- '_DEF$ - Default string
- '_MAXLEN - Size of the "text box" in characters
- '_MOUSE - is this is set to non-zero value, mouse is enabled
- 'The last character in "textbox" is always Space.
- 'The proc uses current curs on/off and pen/paper settings
- '
- Print At(X,Y)+Space$(_MAXLEN);
- Locate X,Y
- LL=Min(Len(_DEF$),_MAXLEN)
- XL=LL+1
- 'Expand the string to _MAXLEN using spaces
- TT$=Left$(_DEF$,_MAXLEN)+Space$(_MAXLEN-LL)
- Mid$(TT$,_MAXLEN,1)=" "
- Print At(X,Y)+TT$;
- Repeat
- Multi Wait
- I$=Inkey$
- 'Mouse
- If _MOUSE and Mouse Key=1
- If Y Text(Y Screen(Y Mouse))=Y
- XL=X Text(X Screen(X Mouse))-X+1
- End If
- End If
- 'Cursor keys
- For Z=78 To 79
- If Key State(Z)
- Add XL,1-(Z-78)*2
- Repeat : Multi Wait : Until Not Key State(Z)
- End If
- Next
- 'Backspace / Delete
- For Z=65 To 70 Step 5
- If Key State(Z)
- If Z=65 and XL>1
- Dec XL
- End If
- For ZZ=XL To _MAXLEN-1
- Mid$(TT$,ZZ,1)=Mid$(TT$,ZZ+1,1)
- Next
- Print At(X,Y)+TT$;
- Repeat : Multi Wait : Until Not Key State(Z)
- End If
- Next
- 'Check da boundaries
- If XL<1 Then XL=1
- If XL>_MAXLEN Then XL=_MAXLEN
- Locate X+XL-1,Y
- If I$<>"" and XL<_MAXLEN
- If Asc(I$)>31
- Print I$;
- Mid$(TT$,XL,1)=I$
- Inc XL
- Else
- Clear Key
- End If
- End If
- Until Key State(68) or Key State(67)
- 'Remove unnecessary spaces from the end
- While Right$(TT$,1)=" "
- TT$=Left$(TT$,Len(TT$)-1)
- Wend
- Clear Key
- End Proc[TT$]
-
-